home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / kopunch.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  6KB  |  244 lines

  1. #include "driver.h"
  2. #include "vidhrdw/generic.h"
  3.  
  4. unsigned char *bsvideoram;
  5. size_t bsvideoram_size;
  6.  
  7. void kopunch_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  8. {
  9.     int i;
  10.  
  11.  
  12. color_prom+=32+32+16+8;
  13.     for (i = 0;i < Machine->drv->total_colors;i++)
  14.     {
  15.         int bit0,bit1,bit2;
  16.  
  17.  
  18.         /* red component */
  19.         bit0 = (*color_prom >> 0) & 0x01;
  20.         bit1 = (*color_prom >> 1) & 0x01;
  21.         bit2 = (*color_prom >> 2) & 0x01;
  22.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  23.         /* green component */
  24.         bit0 = (*color_prom >> 3) & 0x01;
  25.         bit1 = (*color_prom >> 4) & 0x01;
  26.         bit2 = (*color_prom >> 5) & 0x01;
  27.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  28.         /* blue component */
  29.         bit0 = 0;
  30.         bit1 = (*color_prom >> 6) & 0x01;
  31.         bit2 = (*color_prom >> 7) & 0x01;
  32.         *(palette++) = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  33.  
  34.         color_prom++;
  35.     }
  36. }
  37.  
  38. void kopunch_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  39. {
  40.     int offs;
  41. static int bank=0;
  42.  
  43. if (keyboard_pressed_memory(KEYCODE_Z)) bank--;
  44. if (keyboard_pressed_memory(KEYCODE_X)) bank++;
  45.  
  46.     /* for every character in the Video RAM, check if it has been modified */
  47.     /* since last time and update it accordingly. */
  48.     for (offs = videoram_size - 1;offs >= 0;offs--)
  49.     {
  50.         if (dirtybuffer[offs])
  51.         {
  52.             int sx,sy;
  53.  
  54.  
  55.             dirtybuffer[offs] = 0;
  56.  
  57.             sx = offs % 32;
  58.             sy = offs / 32;
  59.  
  60.             drawgfx(tmpbitmap,Machine->gfx[0],
  61.                     videoram[offs],
  62.                     0,
  63.                     0,0,
  64.                     8*sx,8*sy,
  65.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  66.         }
  67.     }
  68.  
  69.  
  70.     /* copy the character mapped graphics */
  71.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  72.  
  73.  
  74.     for (offs = bsvideoram_size - 1;offs >= 0;offs--)
  75.     {
  76.         int sx,sy;
  77.  
  78.  
  79.         sx = offs % 16 + 8;
  80.         sy = offs / 16 + 8;
  81.  
  82.         drawgfx(bitmap,Machine->gfx[1],
  83.                 bsvideoram[offs] + 128 * bank,
  84.                 0,
  85.                 0,0,
  86.                 8*sx,8*sy,
  87.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  88.     }
  89. }
  90.  
  91.  
  92. int kopunch_interrupt(void)
  93. {
  94.     if (keyboard_pressed(KEYCODE_Q)) return 0xef;    /* RST 28h */
  95.     if (keyboard_pressed(KEYCODE_W)) return 0xf7;    /* RST 30h */
  96.     if (keyboard_pressed(KEYCODE_E)) return 0xff;    /* RST 38h */
  97.  
  98.     return ignore_interrupt();
  99. }
  100.  
  101.  
  102. static struct MemoryReadAddress readmem[] =
  103. {
  104.     { 0x0000, 0x1fff, MRA_ROM },
  105.     { 0x2000, 0x23ff, MRA_RAM },
  106.     { -1 }    /* end of table */
  107. };
  108.  
  109. static struct MemoryWriteAddress writemem[] =
  110. {
  111.     { 0x0000, 0x1fff, MWA_ROM },
  112.     { 0x2000, 0x23ff, MWA_RAM },
  113.     { 0x6000, 0x63ff, videoram_w, &videoram, &videoram_size },
  114.     { 0x7000, 0x70ff, MWA_RAM, &bsvideoram, &bsvideoram_size },
  115.     { -1 }    /* end of table */
  116. };
  117.  
  118. static struct IOReadPort readport[] =
  119. {
  120.     { -1 }    /* end of table */
  121. };
  122.  
  123. static struct IOWritePort writeport[] =
  124. {
  125.     { -1 }    /* end of table */
  126. };
  127.  
  128.  
  129.  
  130.  
  131.  
  132. INPUT_PORTS_START( kopunch )
  133.     PORT_START    /* IN0 */
  134. INPUT_PORTS_END
  135.  
  136.  
  137.  
  138. static struct GfxLayout charlayout =
  139. {
  140.     8,8,
  141.     256,
  142.     3,
  143.     { 2*256*8*8, 1*256*8*8, 0*256*8*8 },
  144.     { 7, 6, 5, 4, 3, 2, 1, 0 },
  145.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  146.     8*8
  147. };
  148.  
  149. static struct GfxLayout charlayout2 =
  150. {
  151.     8,8,
  152.     1024,
  153.     3,
  154.     { 2*1024*8*8, 1*1024*8*8, 0*1024*8*8 },
  155.     { 7, 6, 5, 4, 3, 2, 1, 0 },
  156.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  157.     8*8
  158. };
  159.  
  160. static struct GfxDecodeInfo gfxdecodeinfo[] =
  161. {
  162.     { REGION_GFX1, 0, &charlayout,  0, 1 },
  163.     { REGION_GFX2, 0, &charlayout2, 0, 1 },
  164.     { -1 } /* end of array */
  165. };
  166.  
  167.  
  168.  
  169. static struct MachineDriver machine_driver_kopunch =
  170. {
  171.     /* basic machine hardware */
  172.     {
  173.         {
  174.             CPU_Z80,
  175.             3072000,    /* 3.072 Mhz ? */
  176.             readmem,writemem,readport,writeport,
  177.             kopunch_interrupt,1
  178.         }
  179.     },
  180.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  181.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  182.     0,
  183.  
  184.     /* video hardware */
  185.     32*8, 32*8, { 0*8, 32*8-1, 0*8, 32*8-1 },
  186.     gfxdecodeinfo,
  187.     8,8,
  188.     kopunch_vh_convert_color_prom,
  189.  
  190.     VIDEO_TYPE_RASTER,
  191.     0,
  192.     generic_vh_start,
  193.     generic_vh_stop,
  194.     kopunch_vh_screenrefresh,
  195.  
  196.     /* sound hardware */
  197.     0,0,0,0,
  198. };
  199.  
  200.  
  201.  
  202. /***************************************************************************
  203.  
  204.   Game driver(s)
  205.  
  206. ***************************************************************************/
  207.  
  208. ROM_START( kopunch )
  209.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  210.     ROM_LOAD( "epr1105.x",    0x0000, 0x1000, 0x34ef5e79 )
  211.     ROM_LOAD( "epr1106.x",    0x1000, 0x1000, 0x25a5c68b )
  212.  
  213.     ROM_REGION( 0x1800, REGION_GFX1 | REGIONFLAG_DISPOSE )
  214.     ROM_LOAD( "epr1102",      0x0000, 0x0800, 0x8a52de96 )
  215.     ROM_LOAD( "epr1103",      0x0800, 0x0800, 0xbae5e054 )
  216.     ROM_LOAD( "epr1104",      0x1000, 0x0800, 0x7b119a0e )
  217.  
  218.     ROM_REGION( 0x6000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  219.     ROM_LOAD( "epr1107",      0x0000, 0x1000, 0xca00244d )
  220.     ROM_LOAD( "epr1108",      0x1000, 0x1000, 0xcc17c5ed )
  221.     ROM_LOAD( "epr1110",      0x2000, 0x1000, 0xae0aff15 )
  222.     ROM_LOAD( "epr1109",      0x3000, 0x1000, 0x625446ba )
  223.     ROM_LOAD( "epr1112",      0x4000, 0x1000, 0xef6994df )
  224.     ROM_LOAD( "epr1111",      0x5000, 0x1000, 0x28530ec9 )
  225.  
  226.     ROM_REGION( 0x0060, REGION_PROMS )
  227.     ROM_LOAD( "epr1099",      0x0000, 0x0020, 0xfc58c456 )
  228.     ROM_LOAD( "epr1100",      0x0020, 0x0020, 0xbedb66b1 )
  229.     ROM_LOAD( "epr1101",      0x0040, 0x0020, 0x15600f5d )
  230. ROM_END
  231.  
  232.  
  233. static void init_kopunch(void)
  234. {
  235.     unsigned char *RAM = memory_region(REGION_CPU1);
  236.  
  237.     /* patch out bad instruction, either the ROM is bad, or there is */
  238.     /* a security chip */
  239.     RAM[0x119] = 0;
  240. }
  241.  
  242.  
  243. GAME( 1981, kopunch, 0, kopunch, kopunch, kopunch, ROT270, "Sega", "KO Punch" )
  244.